package com.yugao.fintech.libra.shop.cloud;

import com.alibaba.cloud.nacos.NacosServiceAutoConfiguration;
import com.yugao.fintech.framework.assistant.utils.exception.BusinessException;
import com.yugao.fintech.framework.core.response.RetOps;
import com.yugao.fintech.libra.common.module.auth.LoginUser;
import com.yugao.fintech.libra.shop.feign.FumUserClient;
import com.yugao.fintech.libra.model.vo.log.LoginUserGetReq;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.cloud.openfeign.FeignAutoConfiguration;
import org.springframework.stereotype.Service;

@Service
@ConditionalOnClass({FeignAutoConfiguration.class, NacosServiceAutoConfiguration.class})
public class MemberApiCloudImpl {
    @Autowired
    private FumUserClient fumUserClient;
    @Override
    public LoginUser getLoginUser(LoginUserGetReq req) {
        Resp<LoginUser> resp = fumUserClient.getLoginUser(req);
        RetOps.of(resp).assertSuccess(e -> new BusinessException(e.getCode(), e.getMsg()));
        return resp.getData();
    }
}
